package com.manor.main.http;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.orhanobut.logger.Logger;
import com.manor.common.CommonAppConfig;
import com.manor.common.bean.UserBean;
import com.manor.common.bean.UserNBean;
import com.manor.common.http.HttpCallback;
import com.manor.common.http.HttpClient;
import com.manor.common.http.HttpSignCallback;
import com.manor.common.interfaces.CommonCallback;
import com.manor.common.utils.GsonUtil;
import com.manor.common.utils.MD5Util;
import com.manor.common.utils.StringUtil;
import com.manor.common.utils.ToastUtil;
import com.manor.main.bean.SignInfoBean;

/**
 * Created by cxf on 2018/9/17.
 */

public class MainHttpUtil {

    /**
     * 取消网络请求
     */
    public static void cancel(String tag) {
        HttpClient.getInstance().cancel(tag);
    }

    /**
     * 手机号 验证码登录
     */
    public static void login(String phoneNum, String code, HttpCallback callback) {
        HttpClient.getInstance().post("Login.userLogin", MainHttpConsts.LOGIN)
                .params("user_login", phoneNum)
                .params("code", code)

                .execute(callback);
    }


    /**
     * 手机号token登录--闪验
     */
    public static void tokenLogin(String token, String type, HttpCallback callback) {
        HttpClient.getInstance().post("Login.FlashLogin", MainHttpConsts.LOGIN)
                .params("token", token)
                .params("type", type)
                .execute(callback);
    }


    /**
     * 获取登录验证码接口
     */
    public static void getLoginCode(String phoneNum, HttpCallback callback) {
        String sign = MD5Util.getMD5(StringUtil.contact("mobile=", phoneNum, "&", HttpClient.SALT));
        HttpClient.getInstance().get("Login.getCode", MainHttpConsts.GET_LOGIN_CODE)
                .params("mobile", phoneNum)
                .params("sign", sign)
                .execute(callback);
    }

    /**
     * 第三方登录
     */
    public static void loginByThird(String openid, String nicename, String avatar, int flag, HttpCallback callback) {
        String sign = MD5Util.getMD5(StringUtil.contact("openid=", openid, "&", HttpClient.SALT));
        HttpClient.getInstance().get("Login.userLoginByThird", MainHttpConsts.LOGIN_BY_THIRD)
                .params("openid", openid)
                .params("nicename", nicename)
                .params("avatar", avatar)
                .params("type", flag)
                .params("source", 1)
                .params("sign", sign)
                .execute(callback);
    }


    /**
     * 请求签到奖励
     */
    public static void requestBonus(HttpCallback callback) {
        HttpClient.getInstance().get("User.Bonus", MainHttpConsts.REQUEST_BONUS)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }

    /**
     * 获取签到奖励
     */
    public static void getBonus(HttpCallback callback) {
        HttpClient.getInstance().get("User.getBonus", MainHttpConsts.GET_BONUS)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }

    /**
     * 用于用户首次登录设置分销关系
     */
    public static void setDistribut(String code, HttpCallback callback) {
        HttpClient.getInstance().get("User.setDistribut", MainHttpConsts.SET_DISTRIBUT)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("code", code)
                .execute(callback);
    }

    /**
     * 首页直播
     */
    public static void getHot(int p, byte sex, byte chatType, HttpCallback callback) {
        HttpClient.getInstance().get("Home.getHot", MainHttpConsts.GET_HOT)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("sex", sex)
                .params("type", chatType)
                .params("p", p)
                .execute(callback);
    }

    /**
     * 首页
     */
    public static void getFollow(int p, HttpCallback callback) {
        HttpClient.getInstance().get("Home.GetAttention", MainHttpConsts.GET_FOLLOW)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("p", p)
                .execute(callback);

    }

    public static void getBanner(HttpCallback callback) {
        HttpClient.getInstance().get("Slide.Slide_list", MainHttpConsts.GET_NEAR)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("slide_id", 1)
                .execute(callback);
    }

    public static void getNear(int p, String sex, String auth, String video, String voice,
                               String lastId, HttpCallback callback) {
        HttpClient.getInstance().get("Home.getNearby", MainHttpConsts.GET_NEAR)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("lng", CommonAppConfig.getInstance().getLng())
                .params("lat", CommonAppConfig.getInstance().getLat())
                .params("isvideo", video)
                .params("isvoice", voice)
                .params("sex", sex)
                .params("isauth", auth)
                .params("p", p)
                .params("lastid",lastId)
                .execute(callback);
    }

    /**
     * 首页 认证 //公用上面的接口
     */
    public static void getNear(int p, String auth, HttpCallback callback) {
        HttpClient.getInstance().get("Home.getNearby", MainHttpConsts.GET_NEAR)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("lng", CommonAppConfig.getInstance().getLng())
                .params("lat", CommonAppConfig.getInstance().getLat())
                .params("p", p)
                .execute(callback);
    }


    /**
     * 首页 搜索
     * 弃用 ，请使用 {@link MainHttpUtil#getHomeSearch}
     */
    @Deprecated()
    public static void getSeachUser(int p, String keyword, HttpCallback callback) {
        HttpClient.getInstance().get("Home.getNearby", MainHttpConsts.GET_NEAR)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("lng", CommonAppConfig.getInstance().getLng())
                .params("lat", CommonAppConfig.getInstance().getLat())
                .params("keyword", keyword)
                .params("p", p)
                .execute(callback);
    }

    public static void getHomeSearch(int p, String keyword, HttpCallback callback) {
        HttpClient.getInstance().get("Home.Search", MainHttpConsts.GET_SEARCH)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("key", keyword)
                .params("p", p)
                .execute(callback);
    }


    /**
     * 获取用户信息
     */
    public static void getBaseInfo(String uid, String token, final CommonCallback<UserBean> commonCallback) {
        HttpClient.getInstance().getX("User.getBaseInfo", MainHttpConsts.GET_BASE_INFO)
                .params("uid", uid)
                .params("token", token)
                .execute(new HttpSignCallback() {
                    @Override
                    public void onSuccess(int code, String msg, String info) {
                        if (code == 0 && StringUtil.isNotEmpty(info)) {
                            JSONObject obj = JSON.parseObject(info);
                            if (obj.isEmpty())
                                return;
                            Logger.e("getBaseInfo obj ==" + obj);
                            UserNBean nBean = GsonUtil.gsonToBean(info, UserNBean.class);
                            CommonAppConfig.getInstance().putUserInfo(nBean);
                            CommonAppConfig appConfig = CommonAppConfig.getInstance();
                            if (uid.equals(CommonAppConfig.getInstance().getUid())) {
                                appConfig.putUserInfo(nBean);
//                                appConfig.setPriceVideo(obj.getJSONObject("basics").getString("video_value"));
//                                appConfig.setPriceVoice(obj.getJSONObject("basics").getString("voice_value"));
//                                appConfig.setUserSwitchDisturb(obj.getJSONObject("basics").getIntValue("isdisturb") == 1);
//                                appConfig.setUserSwitchVideo(obj.getJSONObject("basics").getIntValue("isvideo") == 1);
//                                appConfig.setUserSwitchVoice(obj.getJSONObject("basics").getIntValue("isvoice") == 1);
//                                appConfig.setUserItemList(obj.getString("list"));
//                                SpUtil.getInstance().setStringValue(SpUtil.USER_INFO, info);
                            }
                            if (commonCallback != null) {
                                commonCallback.callback(appConfig.getUserBean());
                            }
                        }else {
                            if (commonCallback != null) {
                                commonCallback.callback(null);
                            }
                        }
                    }

                    @Override
                    public void onError() {
                        if (commonCallback != null) {
                            commonCallback.callback(null);
                        }
                    }
                });
    }


    /**
     * 获取用户信息
     */
    public static void getBaseInfo(CommonCallback<UserBean> commonCallback) {
        getBaseInfo(CommonAppConfig.getInstance().getUid(),
                CommonAppConfig.getInstance().getToken(),
                commonCallback);
    }

    public static void getBaseInfo(String toUid, final CommonCallback<UserNBean> commonCallback) {
        HttpClient.getInstance().getX("User.getBaseInfo", MainHttpConsts.GET_BASE_INFO)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("v_id", toUid)
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(new HttpSignCallback() {
                    @Override
                    public void onSuccess(int code, String msg, String info) {
                        if (code == 0 && StringUtil.isNotEmpty(info)) {
                            UserNBean nBean = GsonUtil.gsonToBean(info, UserNBean.class);
                            if (toUid.equals(CommonAppConfig.getInstance().getUid())){
                                CommonAppConfig.getInstance().putUserInfo(nBean);
                            }
                            if (commonCallback != null) {
                                commonCallback.callback(nBean);
                            }
                        }
                    }

                    @Override
                    public void onError() {
                        if (commonCallback != null) {
                            commonCallback.callback(null);
                        }
                    }
                });
    }




    /**
     * 用户个人主页信息
     */
    public static void getUserHome(String touid, HttpCallback callback) {
        HttpClient.getInstance().get("User.getUserHome", MainHttpConsts.GET_USER_HOME)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("liveuid", touid)
                .execute(callback);
    }




    /**
     * 获取对方的关注列表
     *
     * @param touid 对方的uid
     */
    public static void getFollowList(String touid, int p, HttpCallback callback) {
        HttpClient.getInstance().post("User.getFollowsList", MainHttpConsts.GET_FOLLOW_LIST)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("touid", touid)
                .params("p", p)
                .execute(callback);
    }

    /**
     * 获取对方的粉丝列表
     *
     * @param touid 对方的uid
     */
    public static void getFansList(String touid, int p, HttpCallback callback) {
        HttpClient.getInstance().post("User.getFansList", MainHttpConsts.GET_FANS_LIST)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("touid", touid)
                .params("p", p)
                .execute(callback);

    }

    /**
     * 获取互粉列表
     */
    public static void getEachFollow(int page, final HttpCallback callback) {
        HttpClient.getInstance().post("User.GetMutual", MainHttpConsts.GET_FANS_LIST)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("page", page)
                .execute(callback);
    }


    /**
     * 更新用户资料
     *
     * @param avatar 头像
     * @param name   昵称
     */
    public static void updateUserInfo(String avatar, String name, HttpCallback callback) {
        HttpClient.getInstance().post("User.UpUserInfo", MainHttpConsts.UPDATE_USER_INFO)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("avatar", avatar)
                .params("name", name)
                .execute(callback);
    }


    /**
     * 礼物柜 获取礼物列表
     */
    public static void getGiftCabList(String liveUid, HttpCallback callback) {
        HttpClient.getInstance().post("User.GetGiftCab", MainHttpConsts.GET_GIFT_CAB_LIST)
                .params("liveuid", liveUid)
                .execute(callback);
    }


    /**
     * 获取自己的相册
     */
    public static void getMyAlbum(int p, HttpCallback callback) {
        HttpClient.getInstance().get("Photo.MyPhoto", MainHttpConsts.GET_MY_ALBUM)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("p", p)
                .execute(callback);
    }


    /**
     * 获取自己的相册
     */
    public static void getAlbumFee(HttpCallback callback) {
        HttpClient.getInstance().get("Photo.GetFee", MainHttpConsts.GET_ALBUM_FEE)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }

    /**
     * 把相册图片信息保存在服务器
     */
    public static void setPhoto(String thumb, int isprivate, String coin, HttpCallback callback) {
        String uid = CommonAppConfig.getInstance().getUid();
        String sign = MD5Util.getMD5(StringUtil.contact("isprivate=", String.valueOf(isprivate), "&thumb=", thumb, "&uid=", uid, "&", HttpClient.SALT));
        HttpClient.getInstance().post("Photo.SetPhoto", MainHttpConsts.SET_PHOTO)
                .params("uid", uid)
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("thumb", thumb)
                .params("isprivate", isprivate)
                .params("coin", coin)
                .params("sign", sign)
                .execute(callback);
    }

    /**
     * 删除自己的相册中的照片
     */
    public static void deletePhoto(String photoId, HttpCallback callback) {
        HttpClient.getInstance().post("Photo.DelPhoto", MainHttpConsts.DELETE_PHOTO)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("photoid", photoId)
                .execute(callback);
    }


    /**
     * 把自己的相册中的私密照片设为公开的
     */
    public static void publicPhoto(String photoId, HttpCallback callback) {
        HttpClient.getInstance().post("Photo.SetPublic", MainHttpConsts.PUBLIC_PHOTO)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("photoid", photoId)
                .execute(callback);
    }


    /**
     * 设置背景墙的封面图
     */
    public static void setWallCover(String thumb, HttpCallback callback) {
        String uid = CommonAppConfig.getInstance().getUid();
        String sign = MD5Util.getMD5(StringUtil.contact("thumb=", thumb, "&uid=", uid, "&", HttpClient.SALT));
        HttpClient.getInstance().post("Wall.SetCover", MainHttpConsts.SET_WALL_COVER)
                .params("uid", uid)
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("thumb", thumb)
                .params("sign", sign)
                .execute(callback);
    }


    /**
     * 获取个人主页相册
     */
    public static void getHomePhoto(String liveuid, int p, HttpCallback callback) {
        HttpClient.getInstance().post("Photo.GetHomePhoto", MainHttpConsts.GET_HOME_PHOTO)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("liveuid", liveuid)
                .params("p", p)
                .execute(callback);
    }


    /**
     * 购买照片
     */
    public static void buyPhoto(String photoId, HttpCallback callback) {
        HttpClient.getInstance().post("Photo.BuyPhoto", MainHttpConsts.BUY_PHOTO)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("photoid", photoId)
                .execute(callback);
    }

    /**
     * 用于更新照片观看量
     */
    public static void photoAddView(String photoId, HttpCallback callback) {
        String uid = CommonAppConfig.getInstance().getUid();
        String sign = MD5Util.getMD5(StringUtil.contact("photoid=", photoId, "&uid=", uid, "&", HttpClient.SALT));
        HttpClient.getInstance().post("Photo.AddView", MainHttpConsts.PHOTO_ADD_VIEW)
                .params("uid", uid)
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("photoid", photoId)
                .params("sign", sign)
                .execute(callback);
    }




    /**
     * 检查是否要弹邀请码的弹窗
     */
    public static void checkAgent(HttpCallback callback) {
        HttpClient.getInstance().post("Agent.Check", MainHttpConsts.CHECK_AGENT)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }

    /**
     * 设置邀请码
     */
    public static void setAgent(String code, HttpCallback callback) {
        HttpClient.getInstance().post("Agent.SetAgent", MainHttpConsts.CHECK_AGENT)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("code", code)
                .execute(callback);
    }
    /*-----------7.22*/

    /**
     * 搜索用户
     */
    public static void searchUser(String key, int p, HttpCallback callback) {
        HttpClient.getInstance().post("Home.search", MainHttpConsts.SEARCH_USER)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("key", key)
                .params("p", p)
                .execute(callback);
    }


    //排行榜  收益榜
    public static void profitList(String type, int p, HttpCallback callback) {
        HttpClient.getInstance().get("Home.profitList", MainHttpConsts.PROFIT_LIST)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("type", type)
                .params("p", p)
                .execute(callback);
    }

    //排行榜  贡献榜
    public static void consumeList(String type, int p, HttpCallback callback) {
        HttpClient.getInstance().get("Home.consumeList", MainHttpConsts.CONSUME_LIST)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("type", type)
                .params("p", p)
                .execute(callback);

    }




    /**
     * 第一次登录更新信息
     *
     * @param uid
     * @param token
     * @param genderType 性别
     * @param date       日期
     * @param callback
     */
    public static void updateAvatar(String uid, String token, String genderType, String date, HttpCallback callback) {
        HttpClient.getInstance().get("Login.UpdateAvatar", MainHttpConsts.GET_FIRST_LOGIN)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("sex", genderType)
                .params("birthday", date)
                .params("code","111127")
                .execute(callback);
    }

    /**
     * 获取今日推荐
     *
     * @param p        页码
     * @param callback
     */
    public static void getRecommended(int p, HttpCallback callback) {
        HttpClient.getInstance().get("Home.GetRecommended", MainHttpConsts.GET_FIRST_LOGIN)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("p", p)
                .execute(callback);
    }
//匹配角标
    public static void getHomeTopTip( HttpCallback callback) {
        HttpClient.getInstance().post("Home.First", MainHttpConsts.GET_HOME_TIP)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .execute(callback);
    }

    /**
     * 获取个人信息
     */
    public static void getCenter(HttpSignCallback callback) {
        HttpClient.getInstance().postX("User.GetCenter", MainHttpConsts.GET_CENTER)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }


    /**
     * 获取社区-同城轮播图
     */
    public static void getSide(HttpCallback callback) {
        HttpClient.getInstance().get("Dynamic.GetSide", MainHttpConsts.GET_SIDE)
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }


    public static void getSignInfo(final CommonCallback<SignInfoBean> commonCallback) {
        HttpClient.getInstance().post("Home.GetSign", MainHttpConsts.GET_SIGN)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(new HttpCallback() {
                    @Override
                    public void onSuccess(int code, String msg, String info) {
                        if (code == 0 && StringUtil.isNotEmpty(info)) {
                            SignInfoBean infoBean = GsonUtil.gsonToBean(info, SignInfoBean.class);
                            if (commonCallback != null) {
                                commonCallback.callback(infoBean);
                            }
                        }
                    }

                    @Override
                    public void onError() {
                        if (commonCallback != null) {
                            commonCallback.callback(null);
                        }
                    }
                });
    }



    public static void getSignLoad(HttpCallback callback) {
        HttpClient.getInstance().post("Home.SetSign", MainHttpConsts.SET_SIGN)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }


    /**
     * 撩一下
     */
    public static void pulledThe(String uid, HttpCallback callback) {
        HttpClient.getInstance().post("Gift.PulledThe", MainHttpConsts.PULLEDTHE)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("liveuid", uid)
                .execute(callback);
    }

    /**
     * 编辑用户资料
     */
    public static void editUserInfo(String k, String v, final CommonCallback<Boolean> commonCallback) {
        HttpClient.getInstance().post("Auth.SetInfo", MainHttpConsts.PULLEDTHE)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("key", k)
                .params("value", v)
                .execute(new HttpCallback() {
                    @Override
                    public void onSuccess(int code, String msg, String info) {
                        ToastUtil.show(msg);
                        if (code == 0) {
                            if (commonCallback != null) {
                                commonCallback.callback(true);
                            }
                        }
                    }

                    @Override
                    public void onError() {
                        super.onError();
                        if (commonCallback != null) {
                            commonCallback.callback(null);
                        }
                    }
                });
    }

    /**
     * 编辑背景图片
     */
    public static void editUserBackdrop(String url, final CommonCallback<Boolean> commonCallback) {
        HttpClient.getInstance().post("Home.Setbackground", MainHttpConsts.PULLEDTHE)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("background", url)
                .execute(new HttpCallback() {
                    @Override
                    public void onSuccess(int code, String msg, String info) {
                        ToastUtil.show(msg);
                        if (code == 0) {
                            if (commonCallback != null) {
                                commonCallback.callback(true);
                            }
                        }
                    }

                    @Override
                    public void onError() {
                        super.onError();
                        if (commonCallback != null) {
                            commonCallback.callback(false);
                        }
                    }
                });
    }

    /**
     * 获取用户信息
     */
    public static void getOtherUserInfo(String toUid, final CommonCallback<UserNBean> commonCallback) {
        HttpClient.getInstance().getX("User.getBaseInfo", MainHttpConsts.GET_BASE_INFO)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("v_id", toUid)
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(new HttpSignCallback() {
                    @Override
                    public void onSuccess(int code, String msg, String info) {
                        if (code == 0 && StringUtil.isNotEmpty(info)) {
                            UserNBean nBean = GsonUtil.gsonToBean(info, UserNBean.class);
                            if (toUid.equals(CommonAppConfig.getInstance().getUid())){
                                CommonAppConfig.getInstance().putUserInfo(nBean);
                            }
                            if (commonCallback != null) {
                                commonCallback.callback(nBean);
                            }
                        }
                    }

                    @Override
                    public void onError() {
                        if (commonCallback != null) {
                            commonCallback.callback(null);
                        }
                    }
                });
    }

    /**
     * 真人认证第一次上传
     *
     * @param urlkey1
     * @param callback
     */
    @Deprecated
    public static void setOneimgAuth(String urlkey1, HttpCallback callback) {
        HttpClient.getInstance().post("Auth.SetOneimgAuth", MainHttpConsts.SetOneimgAuth)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("thumb", urlkey1)
                .execute(callback);

    }

    /**
     * 真人认证上传采集的人脸照片
     *
     * @param url
     */
    @Deprecated
    public static void setAuth(String url,HttpCallback callback) {
        HttpClient.getInstance().post("Auth.SetAuth", MainHttpConsts.SETAUTH)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("thumb", url)
                .execute(callback);
    }

    /**
     * 用于用户已提交的认证信息
     *
     * @param callback
     */
    @Deprecated
    public static void getAuth(HttpCallback callback) {
        HttpClient.getInstance().post("Auth.GetAuth", MainHttpConsts.SetOneimgAuth)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }

    /**
     * 点赞评论消息通知
     *
     * @param p 页码
     */
    public static void getDynamicLog(int p, HttpCallback callback) {
        HttpClient.getInstance().get("Dynamic.GetDynamicLog", MainHttpConsts.DYNAMICLOG)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("p", p)
                .execute(callback);

    }

    /**
     * 点赞评论消息通知未读条数
     *
     * @param callback
     */
    public static void getDynamicToal(HttpSignCallback callback) {
        HttpClient.getInstance().getX("Dynamic.GetDynamicToal", MainHttpConsts.GETDYNAMICTOAL)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .execute(callback);
    }


    /**
     * 通知服务器切换设备登录
     */
    public static void losToken(String uid, String token, HttpCallback callback) {
        HttpClient.getInstance().post("Login.Iostoken", MainHttpConsts.IOSTOKEN)
                .params("uid", uid)
                .params("token", token)
                .params("iostoken", "0")
                .execute(callback);
    }


    /**
     * 用于获取用户收益，包括可体现金额，今日可提现金额
     */
    public static void getMyEarnings(String uid, String token, HttpCallback callback) {
        HttpClient.getInstance().post("Cash.GetProfit", MainHttpConsts.GET_PROFIG)
                .params("uid", uid)
                .params("token", token)
                .execute(callback);
    }


    /**
     * 代充
     */
    public static void getAgentRecharge(String sdNo, String num, String thumb, HttpCallback callback) {
         String token = CommonAppConfig.getInstance().getToken();
        String sign = MD5Util.getMD5(StringUtil.contact("money=", num,"&serial_no=", sdNo,"&token=", token,
                "&", HttpClient.SALT));

        HttpClient.getInstance().post("Cash.DaiChong", MainHttpConsts.GET_PROFIG)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", token)
                .params("serial_no", sdNo)
                .params("money", num)
                .params("type", 1) // 0糖果，1嗨券
                .params("thumb", thumb)
                .params("sign", sign)
                .execute(callback);
    }


    /**
     * 用于设置用户提现账号
     */
    public static void SetUserAccount(String uid, String token,String account,String name, HttpCallback callback) {
        HttpClient.getInstance().post("Cash.SetUserAccount", MainHttpConsts.GET_SETUSETACCOUNT)
                .params("uid", uid)
                .params("token", token)
                .params("type", "1")
                .params("account", account)
                .params("name", name)

                .execute(callback);
    }



       /**
     * 设置收费
     */
    public static void ChargeSet(String uid, String token,String text_value,String voice_value,String video_value, HttpCallback callback) {
        HttpClient.getInstance().post("User.ChargeSet", MainHttpConsts.GET_CHARGESET)
                .params("uid", uid)
                .params("token", token)
                .params("text_value", text_value)
                .params("voice_value", voice_value)
                .params("video_value", video_value)

                .execute(callback);
    }



    /**
     * 用于用户设置语音聊天开关
     */
    public static void SetVoiceSwitch(String uid, String token,String text_value, HttpCallback callback) {
        HttpClient.getInstance().post("User.SetVoiceSwitch", MainHttpConsts.SET_SETVOICESWITCH)
                .params("uid", uid)
                .params("token", token)
                .params("isvoice", text_value)
                .execute(callback);
    }



    /**
     * 用于用户设置视频聊天开关
     */
    public static void SetVideoSwitch(String uid, String token,String text_value,HttpCallback callback) {
        HttpClient.getInstance().post("User.SetVideoSwitch", MainHttpConsts.GET_SETVIDEOSWITCH)
                .params("uid", uid)
                .params("token", token)
                .params("isvideo", text_value)
                .execute(callback);
    }


    /**
     * 用于进行用户提现
     */
    public static void getUserWithdrawal(String uid, String token,String accountid,String cashvote, String cash_type,String thumb, HttpCallback callback) {
        HttpClient.getInstance().post("Cash.SetCash", MainHttpConsts.GET_SETCASH)
                .params("uid", uid)
                .params("token", token)
                .params("accountid", accountid)
                .params("cashvote", cashvote)
                .params("cash_type", cash_type)
                .params("thumb", thumb)
                .execute(callback);
    }
    /**
     * 获取我的守护传uid,获取守护我的传guar_id
     */
    public static void GetGuardList(String uid, String token,String guar_id, HttpCallback callback) {
        if(guar_id.equals("")){
            HttpClient.getInstance().post("Guard.GetGuardList", MainHttpConsts.GET_GETGUARDLIST)
                    .params("uid", uid)
                    .params("token", token)

                    .execute(callback);
        }else {
            HttpClient.getInstance().post("Guard.GetGuardList", MainHttpConsts.GET_GETGUARDLIST)
                    .params("uid", uid)
                    .params("token", token)
                    .params("guar_id", guar_id)
                    .execute(callback);
        }

    }

    /**
     * 用于删除用户提现账号
     */
    public static void getDelUserAccount(String uid, String token,String id, HttpCallback callback) {
        HttpClient.getInstance().get("Cash.DelUserAccount", MainHttpConsts.SET_DELUSETACCOUNT)
                .params("uid", uid)
                .params("token", token)
                .params("id", id)
                .execute(callback);
    }
    /**
     * 用于 获取记录资产变动记录
     */
    public static void getWithdrawal(String uid, int page,String type, HttpSignCallback callback) {
        HttpClient.getInstance().postX("User.GetCreditLog", MainHttpConsts.GET_GETCREDITLOG)
                .params("uid", uid)

                .params("page", page)
                .params("type", type)
                .execute(callback);
    }


    /**
     * 用于 获取收费设置页码数据
     */
    public static void ChargeGet(String uid, String token, HttpSignCallback callback) {
        HttpClient.getInstance().postX("User.ChargeGet", MainHttpConsts.GET_CHARGEGET)
                .params("uid", uid)

                .params("token", token)
                .execute(callback);
    }
    /**
     * 用于 提现记录
     */
    public static void getWithdrawalTxList(String uid, String token, int page,HttpSignCallback callback) {
        HttpClient.getInstance().postX("Cash.SetCashLog", MainHttpConsts.GET_SETCASHLOG)
                .params("uid", uid)

                .params("page", page)
                .params("token", token)
                .execute(callback);
    }

    /**
     * 用于 获取记录资产变动记录
     */
    public static void getWithdrawalAccount(String uid, String token, HttpCallback callback) {
        HttpClient.getInstance().post("Cash.GetUserAccountList", MainHttpConsts.SET_GETUSETACCOUNTLIST)
                .params("uid", uid)

                .params("token", token)
                .execute(callback);
    }
    /**
     * 用于 获取记录资产变动记录
     */
    public static void GetBalance(String uid, String token, HttpCallback callback) {
        HttpClient.getInstance().post("Charge.GetBalance", MainHttpConsts.GET_GETBALANCE)
                .params("uid", uid)

                .params("token", token)
                .params("type", "1")
                .execute(callback);
    }

    /**
     *  用于 获取访客记录
     */
    public static void getGetVisitor(String uid, String token,  String page, HttpCallback callback) {
        HttpClient.getInstance().post("User.GetVisitor", MainHttpConsts.GET_GETVISITOR)
                .params("uid", uid)
                .params("token", token)
                .params("page", page)
                .execute(callback);
    }



    public static void getWithdrawalTxLists(String uid, String token, int page,HttpCallback callback) {
        HttpClient.getInstance().post("Cash.SetCashLog", MainHttpConsts.SET_SETCASHLOG)
                .params("uid", uid)

                .params("page", page)
                .params("token", token)
                .execute(callback);
    }

    /**
     * 首页获得收益宝箱
     */
    public static void getBenefit() {
        HttpClient.getInstance().get("Home.GetBenefit", MainHttpConsts.GET_BENEFIT)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(new HttpCallback() {
                    @Override
                    public void onSuccess(int code, String msg, String info) {
                    }
                });
    }

    /**
     * 个人中心修改手机
     */
    public static void getEditMobile(String thumb, String cell,HttpCallback callback) {
        HttpClient.getInstance().get("User.GetMobile", MainHttpConsts.GET_MOBILE)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("thumb", thumb)
                .params("user_login", cell)
                .execute(callback);
    }

    /**
     * 获取一键打招呼列表
     */
    public static void getGreetList(HttpSignCallback callback) {
        HttpClient.getInstance().getX("Home.GetGreetlist", MainHttpConsts.GET_GREET_LIST)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .execute(callback);
    }


    /**
     * 设置一键打招呼
     */
    public static void setHomeGreet(String ids, String txt,HttpCallback callback) {
        HttpClient.getInstance().post("Home.SetGreetlist", MainHttpConsts.SET_HOME_GREET)
                .params("uid", CommonAppConfig.getInstance().getUid())
                .params("token", CommonAppConfig.getInstance().getToken())
                .params("ids", ids)
                .params("txt", txt)
                .execute(callback);
    }



}




